From 634b06df4c44bef473c3bc24d8ef80a90b0ff728 Mon Sep 17 00:00:00 2001 From: "mjw@wray-m-3.hpl.hp.com" Date: Tue, 13 Jul 2004 12:44:25 +0000 Subject: [PATCH] bitkeeper revision 1.1075 (40f3d929OFHwDCndxHCAhHnmUAclPg) Improve error trapping in xm. Allow nfs_server to override dummy addr. --- tools/python/xen/xend/Args.py | 4 ++-- tools/python/xen/xend/XendClient.py | 2 +- tools/python/xen/xm/create.py | 11 +++++------ tools/python/xen/xm/main.py | 4 +++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/python/xen/xend/Args.py b/tools/python/xen/xend/Args.py index f70000a9d5..8920a65d1b 100644 --- a/tools/python/xen/xend/Args.py +++ b/tools/python/xen/xend/Args.py @@ -107,11 +107,11 @@ class Args: def call_with_args(self, fn, args, xargs=None): (params, keys) = self.get_args(args, xargs=xargs) - fn(*params, **keys) + return fn(*params, **keys) def call_with_form_args(self, fn, fargs, xargs=None): (params, keys) = self.get_form_args(fargs, xargs=xargs) - fn(*params, **keys) + return fn(*params, **keys) class ArgFn(Args): """Represent a remote HTTP operation as a function. diff --git a/tools/python/xen/xend/XendClient.py b/tools/python/xen/xend/XendClient.py index add488023b..a6077ab20d 100644 --- a/tools/python/xen/xend/XendClient.py +++ b/tools/python/xen/xend/XendClient.py @@ -136,7 +136,7 @@ def xend_request(url, method, data=None): #if isinstance(val, types.ListType) and sxp.name(val) == 'val': # val = val[1] if isinstance(val, types.ListType) and sxp.name(val) == 'err': - raise RuntimeError(val[1]) + raise XendError(val[1]) if DEBUG: print '**val='; sxp.show(val); print return val diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py index 1e6b7dce4a..ea1d1b020d 100644 --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -347,8 +347,9 @@ def preprocess_ip(opts, vals): setip = (vals.hostname or vals.netmask or vals.gateway or vals.dhcp or vals.interface) if not setip: return + dummy_nfs_server = '1.2.3.4' ip = (vals.ip - + ':' + '1.2.3.4' + + ':' + (vals.nfs_server or dummy_nfs_server) + ':' + vals.gateway + ':' + vals.netmask + ':' + vals.hostname @@ -357,11 +358,9 @@ def preprocess_ip(opts, vals): vals.cmdline_ip = ip def preprocess_nfs(opts, vals): - if (vals.nfs_root or vals.nfs_server): - if (not vals.nfs_root) or (not vals.nfs_server): - opts.err('Must set nfs root and nfs server') - else: - return + if not vals.nfs_root: return + if not vals.nfs_server: + opts.err('Must set nfs root and nfs server') nfs = 'nfsroot=' + vals.nfs_server + ':' + vals.nfs_root vals.extra = nfs + ' ' + vals.extra diff --git a/tools/python/xen/xm/main.py b/tools/python/xen/xm/main.py index d8ac0d43e6..e624447955 100644 --- a/tools/python/xen/xm/main.py +++ b/tools/python/xen/xm/main.py @@ -9,7 +9,7 @@ import socket from xen.xend import PrettyPrint from xen.xend import sxp -from xen.xend.XendClient import server +from xen.xend.XendClient import XendError, server from xen.xend.XendClient import main as xend_client_main from xen.xm import create, shutdown @@ -72,6 +72,8 @@ class Xm: except socket.error, ex: print >>sys.stderr, ex self.err("Error connecting to xend, is xend running?") + except XendError, ex: + self.err(str(ex)) def main_call(self, args): """Main entry point. Dispatches to the progs. -- 2.30.2